﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Repass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "修改密码";
        if (Session["UID"] == null)
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        string username = Session["xingming"].ToString();
        string u = Session["ygbh"].ToString();
        string idcard = Session["idcards"].ToString().Substring(Session["idcards"].ToString().Length - 4, 4);
        scjrm.WebServiceGZ Web = new scjrm.WebServiceGZ();
        if (newpass.Text != pass.Text)
        {
            MessageBox.Text = "新密码不一致";
            return;
        }

        if (newpass.Text == oldpass.Text)
        {
            MessageBox.Text = "新密码不能和老密码一样";
            return;
        }
       
            if (newpass.Text.Length < 5)
        {
            MessageBox.Text = "新密码必须大于等于6位";
            return;
        }       

        int info = Web.Repass(u, oldpass.Text, idcard, newpass.Text);
        if (info == 1)
        {
            MessageBox.Text = "修改成功";
            Session["UID"] = "";
            Response.Redirect("Login.aspx");
        }
        else
        {
            MessageBox.Text = "密码修改失败请重试";
        }
    }
}
